# -*- coding: utf-8 -*-
import sqlite3,xlwt

# conn=sqlite3.connect('merge_err.db3')
conn=sqlite3.connect('cif_company.db3')
conn.text_factory = str
vessel=['SANTAREBECCA','KOTALAHIR','E.R.YANTIAN','RHLFIDELITAS','KOTALAGU','KOTACARUM','KOTAKAMIL','KOTAGUNAWAN','KOTAKARIM','KOTAKASTURI','KOTALAJU']
vessel=['KOTANELAYAN','KOTANEBULA','HANSARAVENSBURG','KOTANASRAT','KOTANALURI','KOTANEKAD','KOTANAZIM','KOTANAZAR','KOTANAGA','KOTANABIL','KOTANILAM','WEHRRISSEN','KOTANIPAH']
vessel=('CHUANHE','COSCOHAMBURG','COSCODALIAN','COSCOROTTERDAM','CSCLNINGBO','EVERUNIFIC','EYERUTILE','HANJINKAOHSIUNG','HANJINOSAKA','HANJINPORTLAND ','ITALLAGUNA','OPT','SANTAPRISCILLA','SEASPANNINGBO ','XINCHANGSHU','XINNANSHA','YMOAKLAND','YMSEATTLE')
wbk=xlwt.Workbook()
for v in vessel:
    sheet=wbk.add_sheet(v)
    company=[c[0] for c in conn.execute("select distinct c from [cif_vc] where v=?",(v,)).fetchall()]
    # print ','.join(company).decode('utf-8')
    for row in xrange(len(company)):
        sheet.write(row,0,company[row].decode('utf-8'))
wbk.save('cif.xls')
conn.close()    





        